import type { MockMethod } from 'vite-plugin-mock'
import Mock from 'mockjs'

// 测试用的 mock 接口
export const testMock: MockMethod[] = [
  {
    url: '/api/test',
    method: 'get',
    response: () => {
      return {
        code: 200,
        message: 'Mock 测试成功',
        data: Mock.mock({
          'list|1-10': [{
            'id|+1': 1,
            'name': '@cname',
            'email': '@email',
            'date': '@date'
          }]
        })
      }
    }
  },
  {
    url: '/api/user/info',
    method: 'post',
    response: ({ body }: { body: unknown }) => {
      return {
        code: 200,
        message: '获取用户信息成功',
        data: {
          id: Mock.mock('@id'),
          username: Mock.mock('@cname'),
          avatar: Mock.mock('@image("100x100")'),
          email: Mock.mock('@email'),
          phone: Mock.mock('@phone'),
          createTime: Mock.mock('@datetime')
        }
      }
    }
  }
]
